@file:Suppress("unused")

package com.example.demo.model.mall

import xyz.erupt.annotation.*
import xyz.erupt.annotation.sub_erupt.*
import xyz.erupt.annotation.sub_field.*
import xyz.erupt.annotation.sub_field.sub_edit.*
import xyz.erupt.jpa.model.*
import javax.persistence.*

@Erupt(name = "商品类别", tree = Tree(pid = "parent.id"), orderBy = "GoodsCategory.sort")
@Table(name = "mall_goods_category")
@Entity
class GoodsCategory : BaseModel() {

    @EruptField(
        edit = Edit(
            title = "分类图片",
            type = EditType.ATTACHMENT,
            attachmentType = AttachmentType(type = AttachmentType.Type.IMAGE),
        ),
    )
    var image: String? = null

    @EruptField(edit = Edit(title = "类别名称", notNull = true))
    var name: String = ""

    @EruptField(edit = Edit(title = "显示顺序"))
    var sort: Int = 0

    @ManyToOne
    @EruptField(
        edit = Edit(
            title = "上级分类",
            type = EditType.REFERENCE_TREE,
            referenceTreeType = ReferenceTreeType(pid = "parent.id"),
        ),
    )
    var parent: GoodsCategory? = null

}